package Lab03;

import org.apache.commons.dbcp.BasicDataSource;

import java.sql.Connection;
import java.sql.SQLException;
//连接池
public class DBCP {
    private static BasicDataSource bds = new BasicDataSource();
    static {
        bds.setUrl("jdbc:mysql://127.0.0.1");
        bds.setUsername("root");
        bds.setPassword("root");
    }
    public static Connection getConnection(){
        try {
            return bds.getConnection();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
